{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "for i in range(1,10):\n",
    "    for j in range (1,10): \n",
    "        if i>=j: # 这里的if条件，可以直接提到for循环的条件里面\n",
    "            print (\"{}*{}={} \".format(i, j, i*j),end=' ')\n",
    "    print('\\n ')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "u='amelie'\n",
    "p='87'\n",
    "i=3\n",
    "while True:\n",
    "    if i>0: # 这里if判断，可以直接放到上面的while True里面，改成while i：这个判断，缩减代码\n",
    "        user_name=input (\"请输入登录用户名:\")\n",
    "        user_pw=input(\"请输入用户密码：\")\n",
    "        if u==user_name and p==user_pw:\n",
    "            print(\"登录成功!\")\n",
    "            break\n",
    "        else:\n",
    "            i-=1\n",
    "            print(\"登录失败，还有次{}机会！\".format(i))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
